import React, { Component } from 'react'

export default class Test extends Component {
  state = {
    xxx: 0,
  }

  static getDerivedStateFromProps(props, state) {
    // props是当前组件接收的props数据
    // state是当前组件的状态
    // console.log(props, state)
    return {
      xxx: state.xxx + props.length,
    }
  }
  render() {
    return (
      <div>
        Test,
        <p>{this.state.xxx}</p>
      </div>
    )
  }
}
